package com.gxar.quick.ar.server.base.common.enums;

import java.util.Arrays;
import java.util.Optional;

/**
 * @author linsy
 * @version 1.0
 * @created 2023/11/9 18:06
 */
public enum ComboGradeEnum {

    ORDINARY(0, "Ordinary", "普通版", "普通版"),
    PERSONAL_BASIC(1, "PersonalBasic", "个人基础版", "基础会员"),
    PERSONAL_BASIC_YEAR(2, "PersonalBasicYear", "个人基础版-年卡", "基础会员"),
    Premium(3, "Premium", "高级版", "高级会员"),
    ;

    private final Integer code;
    private final String name;
    private final String desc;
    private final String nickName;

    /**
     * 根据code获取等级
     *
     * @param code code
     * @return 等级
     */
    public static ComboGradeEnum getByCode(Integer code) {
        Optional<ComboGradeEnum> comboGradeEnum = Arrays.stream(ComboGradeEnum.values()).filter(e -> e.getCode().equals(code)).findFirst();
        return comboGradeEnum.orElse(null);
    }

    ComboGradeEnum(Integer code, String name, String desc, String nickName) {
        this.code = code;
        this.name = name;
        this.desc = desc;
        this.nickName = nickName;
    }

    public Integer getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public String getDesc() {
        return desc;
    }

    public String getNickName() {
        return nickName;
    }

}
